package com.myoffice.action;

import java.sql.Driver;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;

import com.myoffice.biz.SysFunBiz;
import com.myoffice.pageModel.DataGrid;
import com.myoffice.pageModel.Sysfun;
import com.myoffice.pageModel.base.Json;
import com.opensymphony.xwork2.ModelDriven;

@ParentPackage("basePackage")
@Namespace("")
@Action(value="sysfunAction")
public class SysfunAction extends BaseAction implements ModelDriven<Sysfun>{
	private Sysfun sysFun= new Sysfun();
	
	public Sysfun getModel() {
		return sysFun;
	}
	
	private SysFunBiz sysFunBiz=null;
	
	public SysFunBiz getSysFunBiz() {
		return sysFunBiz;
	}
	@Autowired
	public void setSysFunBiz(SysFunBiz sysFunBiz) {
		this.sysFunBiz = sysFunBiz;
	}

	public void getTree(){
		super.writeJson(this.sysFunBiz.getTree(sysFun));
	}
	public void gridTree(){
	     DataGrid d=new DataGrid();
		 d=this.sysFunBiz.gridTree(sysFun);
		 super.writeJson(d);
	}
	
	/** 
	 * 添加菜单
	 */
	public void addCdgl(){
		Json j=new Json();
		sysFun=this.sysFunBiz.addCdgl(sysFun);
		if(sysFun!=null){
			j.setObj(sysFun);
			j.setMsg("添加成功！");
			j.setSuccess(true);
		}
		super.writeJson(j);
	}
	/**
	 * 删除菜单管理 
	 */
	public void removeCdgl(){
		Json j=new Json();
		this.sysFunBiz.removeCdgl(sysFun.getIds());
		j.setMsg("删除成功！");
		j.setSuccess(true);
	}
}
